import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import axios from "axios";
import VueAxios from "vue-axios";
import { switchStatement } from "@babel/types";

axios.defaults.withCredentials = true;
axios.defaults.baseURL = "http://localhost:9090";
axios.defaults.timeout = 1200;

axios.interceptors.response.use(
  (res) => {
    console.log(
      "拦截器拦截到正常回复： 监控一下 ：" + JSON.stringify(res.data)
    );
    return res;
  },
  (error) => {
    //    重要舞台 重要拦截器内容
    if (error && error.response) {
      let s = error.response.status;
      if (s === 404) {
        console.log("资源未找到");
      } else if (s === 713) {
        console.log("controller自定义异常" + error.response.data);
      } else if (s === 712) {
        ElementUI.Message.error("controller自定义异常" + error.response.data);
      } else {
        console.log("未知异常");
      }
    }
    throw error;
  }
);

Vue.use(ElementUI);
Vue.use(VueAxios, axios);
Vue.config.productionTip = false;
import mavonEditor from "mavon-editor";
import "mavon-editor/dist/css/index.css";
// use
Vue.use(mavonEditor);
new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
